package com.aimashi.railwaytoolmanagesystem.activity.history;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.aimashi.railwaytoolmanagesystem.R;
import com.aimashi.railwaytoolmanagesystem.bean.GoodMode;

public class GoodsAdapter extends BaseAdapter {
	private List<GoodMode> list;
	private LayoutInflater inflater;

	public GoodsAdapter(Context context, List<GoodMode> list) {
		this.list = list;
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public GoodMode getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		GoodMode map = this.getItem(position);
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = inflater.inflate(R.layout.hostory_good_item, null);

			viewHolder.goodInfoText = (TextView) convertView.findViewById(R.id.goodInfoText);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		
		String tempStr =  map.isBack()? "吻合":"不吻合";
		viewHolder.goodInfoText.setText(map.getEpcDesc() + " 【" + tempStr +"】");

		return convertView;
	}

	public static class ViewHolder {
		public TextView goodInfoText;
	}

}
